//
//  StatusCellBottomView.swift
//  mySina
//
//  Created by mac on 15/12/21.
//  Copyright © 2015年 tz. All rights reserved.
//

import UIKit
import SnapKit
class StatusCellBottomView: UIView {
    
    @objc func commentBtnDidClick() {
        print(__FUNCTION__)
        let temp = TempViewController()
        self.navController()?.pushViewController(temp, animated: true)
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setupUI() {
        //添加子视图
        addSubview(retweetBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        //添加约束
        retweetBtn.snp_makeConstraints { (make) -> Void in
            make.top.left.bottom.equalTo(self)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.equalTo(self)
            make.width.equalTo(retweetBtn.snp_width)
            make.left.equalTo(retweetBtn.snp_right)
        }
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.right.equalTo(self)
            make.width.equalTo(commentBtn.snp_width)
            make.left.equalTo(commentBtn.snp_right)
        }
        //添加分割线
        let sepView1 = sepView()
        let sepView2 = sepView()
        let w:CGFloat = 0.5
        let scale = 0.4
        //添加子视图
        addSubview(sepView1)
        addSubview(sepView2)
        //添加约束
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetBtn.snp_right)
            make.width.equalTo(w)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.width.equalTo(w)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
        }
        //添加点击事件
        commentBtn.addTarget(self, action: "commentBtnDidClick", forControlEvents: .TouchUpInside)
    }
    //生成分割线
    private func sepView() -> UIView {
        let v = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
        return v
    }
    //懒加载所有的子控件
    //转发
    private lazy var retweetBtn:UIButton = UIButton(title: "注册", backImageName: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet")
    //评论
    private lazy var commentBtn:UIButton = UIButton(title: "评论", backImageName: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_comment")
    //赞
    private lazy var likeBtn:UIButton = UIButton(title: "赞", backImageName: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike")
}
